/*
 *  v8defines.h
 *  wonderland-project
 *
 *  Created by Ben Nolan on 8/10/08.
 *  Copyright 2008 Nolan Consulting Limited. All rights reserved.
 *
 */

#define V8CALLBACK(type, name)\
 v8::Handle<v8::Value> type ## _ ## name(const v8::Arguments& args)
#define V8_GETTER(type, property) \
  v8::Handle<v8::Value> type ## _get ## property(v8::Local<v8::String> property, const v8::AccessorInfo& args)
#define V8_SETTER(type, property) \
  void type ## _set ## property(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& args)
#define V8INTERNAL(type)\
 	(static_cast<type>(v8::Local<v8::External>::Cast(args.Holder()->GetInternalField(0))->Value()))

// Check argument to callbacks
#define V8ARGUMENT(type, index)\
 	(static_cast<type>(v8::Local<v8::External>::Cast(args[index]->ToObject()->GetInternalField(0))->Value()))
#define V8ARGUMENTTYPE(type, index)\
  ( \
    args[index]->IsObject() \
    && (args[index]->ToObject()->InternalFieldCount()==2) \
    && (*v8::String::Utf8Value(args[index]->ToObject()->GetInternalField(1)->ToString())==std::string(type))  \
  )
